﻿using System;
namespace Producers.Kis.Xtee.Riik.Ee.Producer.Kis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="StateFeeCourt", Namespace="http://producers.kis.xtee.riik.ee/producer/kis", Target=typeof(StateFeeCourt))]
    public class StateFeeCourtSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IStateFeeCourt clazz;
        
        public StateFeeCourtSerializer(IStateFeeCourt clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Amount");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.Amount))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("PaymentDate");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.PaymentDate))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Account");
            if (clazz.Account!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "NonEmptyString");
                Writer.WriteString(clazz.Account.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Account");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("BankName");
            if (clazz.BankName!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "NonEmptyString");
                Writer.WriteString(clazz.BankName.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : BankName");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("PaidWithBankLink");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.PaidWithBankLink))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ReferenceNumber");
            if (clazz.ReferenceNumber!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "NonEmptyString");
                Writer.WriteString(clazz.ReferenceNumber.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ReferenceNumber");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("RemitterName");
            if (clazz.RemitterName!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "NonEmptyString");
                Writer.WriteString(clazz.RemitterName.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : RemitterName");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("StateFeeStatement");
            if (clazz.StateFeeStatement!=null) {
                Writer.WriteTypeAttribute("http://producers.kis.xtee.riik.ee/producer/kis", "NonEmptyString");
                Writer.WriteString(clazz.StateFeeStatement.ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : StateFeeStatement");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Amount") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>Amount");
                }
                clazz.Amount = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("Amount")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>Amount", Reader.LocalName);
            }
            if (Reader.LocalName=="PaymentDate") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>PaymentDate");
                }
                clazz.PaymentDate = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("PaymentDate")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>PaymentDate", Reader.LocalName);
            }
            if (Reader.LocalName=="Account") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>Account");
                }
                clazz.Account = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.NonEmptyString(Reader.ReadElementString("Account"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>Account", Reader.LocalName);
            }
            if (Reader.LocalName=="BankName") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>BankName");
                }
                clazz.BankName = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.NonEmptyString(Reader.ReadElementString("BankName"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>BankName", Reader.LocalName);
            }
            if (Reader.LocalName=="PaidWithBankLink") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>PaidWithBankLink");
                }
                clazz.PaidWithBankLink = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("PaidWithBankLink")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>PaidWithBankLink", Reader.LocalName);
            }
            if (Reader.LocalName=="ReferenceNumber") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>ReferenceNumber");
                }
                clazz.ReferenceNumber = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.NonEmptyString(Reader.ReadElementString("ReferenceNumber"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>ReferenceNumber", Reader.LocalName);
            }
            if (Reader.LocalName=="RemitterName") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>RemitterName");
                }
                clazz.RemitterName = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.NonEmptyString(Reader.ReadElementString("RemitterName"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>RemitterName", Reader.LocalName);
            }
            if (Reader.LocalName=="StateFeeStatement") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>StateFeeCourt>StateFeeStatement");
                }
                clazz.StateFeeStatement = new global::Producers.Kis.Xtee.Riik.Ee.Producer.Kis.NonEmptyString(Reader.ReadElementString("StateFeeStatement"));
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>StateFeeCourt>StateFeeStatement", Reader.LocalName);
            }
        }
    }
}
